const _ = require('underscore')

module.exports = {

  isSingle (discipline) {
    if (discipline === 'ms' || discipline === 'ws' || discipline === 's') return true
    return false
  },

  genGroupMatches (arr) {
    var ret = []
    arr.forEach((el, index, arr) => {
      return arr.slice(index + 1).forEach(el2 => {
        ret.push({
          state: 'preparing',
          teams: [el, el2].map(el => {
            return {objectId: el}
          })
        })
      })
    })
    return ret
  },

  arrGroup (arr, groupsLen) {
    var len = arr.length
    var size = Math.floor(len / groupsLen)
    var ret = _.range(groupsLen)
    return ret.map((el, index) => {
      return index !== groupsLen - 1 ? arr.slice(index, index + size) : arr.slice(index)
    })
  }

}
